document.addEventListener('DOMContentLoaded', function () {
  const erjiTab = document.querySelector('.erji');
  const chuandaiTab = document.querySelector('.chuandai');
  const ejContent = document.querySelector('.ej');
  const cdContent = document.querySelector('.cd');
  // 切换标签的函数
  function switchTab (activeTab, inactiveTab, showContent, hideContent) {
    // 添加激活类到当前标签
    activeTab.classList.add('tab-active');
    inactiveTab.classList.remove('tab-active');

    // 显示对应内容
    showContent.style.display = 'block';
    hideContent.style.display = 'none';
  }

  // 耳机标签事件
  erjiTab.addEventListener('mouseenter', function () {
    switchTab(erjiTab, chuandaiTab, ejContent, cdContent);
  });

  // 穿戴标签事件
  chuandaiTab.addEventListener('mouseenter', function () {
    switchTab(chuandaiTab, erjiTab, cdContent, ejContent);
  });

  // 初始化默认显示耳机内容
  erjiTab.classList.add('tab-active');
});